<?php

namespace RedMVC\Drawing\Color;
use RedMVC;

/**
 * Cmyk class
 *
 * @category    RedMVC
 * @package     Drawing 
 * @subpackage  Color 
 * @author      Jan Fischer, bitWorking <info@bitworking.de>
 */
class Cmyk{

    public $c;
    public $m;
    public $y;
    public $k;
    
    public function __construct($c, $m, $y, $k){
        $this->c = min(max($c, 0), 100);
        $this->m = min(max($m, 0), 100);
        $this->y = min(max($y, 0), 100);
        $this->k = min(max($k, 0), 100);
    }
    
    public static function normalize(Cmyk $cmyk){
        $self = new self($cmyk->c / 100, $cmyk->m / 100, $cmyk->y / 100, $cmyk->k / 100);
        return $self;
    }
    
    public function __toString(){
        return 'cmyk('.$this->c.','.$this->m.','.$this->y.','.$this->k.')';
    }
    
    public function toHex(){
        return RedMVC\Drawing\Color::cmyk2hex($this);
    }

}